<?php

namespace app\common\library;

use app\common\controller\BasicApi;
use app\common\model\UserModel;

/**
 * Class Wechat
 */
class Wechat extends BasicApi
{
    /**
     * 获取小程序配置
     * @return array
     */
    private function config()
    {
        return config('wechat.miniapp');
    }

    /**
     * 发送订阅信息
     */
    public function sendSubscribeMsg()
    {
        $data = [
            "touser"=> "OPENID",
            "template_id"=> "TEMPLATE_ID",
            "page"=> "index",
            "data"=> [
                "name01"=> ["value"=> "某某"],
                "amount01"=> ["value"=> "￥100"],
                "thing01"=> ["value"=> "广州至北京"],
                "date01"=> ["value"=> "2018-01-01"]
            ]
        ];

        $ret = \We::WeMiniTemplate($this->config())->send($data);
        $this->success('发送订阅消息成功！');
    }

}